home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Demos / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Waves / Wave Loading < prev    next >
Encoding:
Text File  |  1994-06-03  |  2.7 KB  |  90 lines  |  [TEXT/IGR0]

  1. #include <Execute Cmd On List>
  2. Menu "Load Waves"
  3.     "-"
  4.     "Load All Waves In Folder..."
  5. End
  6.  
  7. Menu "Data"
  8.     "-"
  9.     "Copy All Waves To Home..."
  10. End
  11.  
  12. | LoadAllWavesInFolder - Loads all Igor Binary files or all Text files in a folder as waves.
  13. Proc LoadAllWavesInFolder(type,naming,precision,base,overwrite,makeTable,copyToHome,otherFlags)
  14.     Variable type,naming,overwrite,precision,makeTable,copyToHome,
  15.     String base="wave",otherFlags
  16.     Prompt type,"data in file:",popup,"Igor Binary;Igor Text;General Text;Delimited Text;"
  17.     Prompt naming,"assign text file wave names:",popup,"auto names using base name;from file, no name dialog;from file, name dialog;"
  18.     Prompt precision,"precision of loaded text:",popup,"double [64 bits];single [32 bits];"
  19.     Prompt base,"auto names start with:"
  20.     Prompt overwrite,"overwrite existing waves?:",popup,"Yes;No;"
  21.     Prompt makeTable,"table options:",popup,"_none_;create new table for waves;append waves to top table;"
  22.     Prompt copyToHome,"copy Igor Binary wave(s) to home?:",popup,"yes: files not needed anymore;no: files are part of experiment"
  23.     Prompt otherFlags,"enter any other LoadWave flags:"
  24.     
  25.     Silent 1;PauseUpdate
  26.     Variable jg=0
  27.     String fileType="TEXT"
  28.     String cmd= "LoadWave"
  29.     if( makeTable > 1 )
  30.         cmd+="/E=2"    | always append, so multiple file loads are on same table.
  31.     endif
  32.     if( copyToHome==1 )
  33.         cmd+="/H"
  34.     endif
  35.     if( overwrite==1 )
  36.         cmd+="/O"
  37.     endif
  38.     if( type == 1 )
  39.         fileType="IGBW"    | Igor Binary
  40.     else
  41.     if( type == 2 )    
  42.         cmd+="/T"        | Igor Text
  43.     else
  44.     if( type == 3 )
  45.         cmd+="/G"; jg=1    | General Text
  46.     else
  47.     if( type == 4 )
  48.         cmd+="/J"; jg=1    | Delimited Text
  49.     endif
  50.     endif
  51.     endif
  52.     endif
  53.     if( jg )    | some options apply only to /J or /G
  54.         if( naming == 1 )        | auto base
  55.             cmd+="/A"
  56.             if( strlen(base) > 0 )
  57.                 cmd+= "="+base
  58.             endif
  59.         else                    | from file
  60.             cmd+="/W"
  61.             if( naming == 2 )
  62.                 cmd+="/A"    | trust file contents, no dialog
  63.             endif
  64.         endif
  65.         if( precision == 1 )     | double
  66.             cmd+="/D"
  67.         endif
  68.     endif
  69.     cmd+= otherFlags + "/P=dataFolder \"%s\""
  70.     NewPath/O/M="select folder of Igor Binary waves"  dataFolder    | dialog
  71.     String files= IndexedFile(dataFolder,-1,fileType)    | list of all files
  72.     if( makeTable == 2 )
  73.         Edit    | blank table to append to
  74.     endif
  75.     ExecuteCmdOnList(cmd, files)
  76. End
  77.  
  78. | The CopyAllWavesToHome macro copies all waves in the experiment to home,
  79. | which adopts all shared waves so that references to external files are no longer
  80. | needed (see Sharing Versus Copying Igor Binary Files):
  81. Proc CopyAllWavesToHome()
  82.     PathInfo home
  83.     if( V_Flag == 0 )
  84.         Abort "Home path not defined. You must save the experiment to define it."
  85.     endif
  86.     DoAlert 1,"This operation is not undoable.\r\rReally copy all shared waves into this experiment?"
  87.     if( V_Flag == 1)
  88.         ExecuteCmdOnList("Save/P=home/O %s", WaveList("*",";",""))
  89.     endif
  90. End